/*
 * Copyright (c) www.bugull.com
 */

package com.bugull.farm.app.balancer.handler;

import com.bugull.farm.core.cache.PropertiesCache;
import com.bugull.farm.core.frame.structure.Frame;
import com.bugull.farm.core.handler.AbstractAppFrameHandler;
import com.bugull.farm.core.handler.Processor;
import io.netty.channel.ChannelHandlerContext;

/**
 *
 * @author Frank Wen(xbwen@hotmail.com)
 */
public class MyAppFrameHandler extends AbstractAppFrameHandler {

    @Override
    protected void processFrame(ChannelHandlerContext ctx, Frame frame) throws Exception {
        byte cmd = frame.getByte("cmd");
        if(cmd == PropertiesCache.getInstance().getByte("cmd.app.worker")){
            Processor processor = new AppWorkerProcessor();
            processor.process(ctx, frame);
        }else{
            ctx.close();
        }
    }

}
